<template>
  <el-dialog title="备选配送" :visible.sync="dialogVisible" width="35%" @close="handleClose">
    <el-radio-group class="mar_t30" v-model="radio" style="width: 100%;">
      <template v-for="item of dataList">
        <el-radio :label="item.value" class="mar_b30" v-if="filtersFun(item.value)" :key="item.value">{{ item.value == 4 || item.value == 9 ? (item.value == 4 ? configInfo.makeName : configInfo.yunbeiName ) : item.label }}</el-radio>
      </template>
    </el-radio-group>
    <div class="color_9 fon_12">备注：手动选择备选配送方式之后，此订单将按备选配送方式配送，请谨慎选择！</div>
    <span slot="footer" class="dialog-footer">
      <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
      <el-button size="mini" type="primary" @click="confirm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    configInfo: {
      type: Object,
      defalut: () => {
        return {};
      }
    }
  },
  data() {
    return {
      radio: '',
      dialogVisible: false,
      dataList: [
        {
          value: '1',
          label: '商户配送'
        },
        {
          value: '2',
          label: '达达配送'
        },
        {
          value: '3',
          label: '点我达'
        },
        {
          value: '4',
          label: '小程序make配送'
        },
        {
          value: '5',
          label: '顺丰同城'
        },
        {
          value: '6',
          label: '蜂鸟即配'
        },
        {
          value: '7',
          label: '闪送'
        },
        {
          value: '8',
          label: 'uu跑腿'
        },
        {
          value: '9',
          label: '小程序云贝配送'
        }
      ],
      id: ''
    };
  },
  methods: {
    init(id) {
      this.id = id;
      this.dialogVisible = true;
    },
    handleClose() {
      this.$emit('close');
    },
    confirm() {
      if (this.radio) {
        this.dialogVisible = false;
        this.$emit('confirm', this.id, this.radio);
      } else {
        this.$baseMessage('请选择配送方式！', 'warning');
      }
    },
    filtersFun(msg) {
      const ind = this.configInfo.alternative.indexOf(msg) >= 0;
      return ind;
    }
  }
};
</script>